package com.zrq.secondkill.controller;

import com.zrq.secondkill.error.BusinessException;
import com.zrq.secondkill.response.CommonReturnType;
import com.zrq.secondkill.service.PromoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/promo")
public class PromoController {

    final
    PromoService promoService;

    public PromoController(PromoService promoService) {
        this.promoService = promoService;
    }

    @PostMapping("/publishPromo")
    public CommonReturnType publishPromo(@RequestParam("promoId") String promoId) throws BusinessException {
        promoService.publishPromo(Integer.valueOf(promoId));
        return CommonReturnType.create("发布成功");
    }
}
